package org.wu.framework.authorization.platform.application.assembler;


import org.wu.framework.authorization.platform.application.command.SysUserRoleCommand;
import org.wu.framework.authorization.platform.application.dto.SysUserRoleDTO;
import org.wu.framework.authorization.platform.domain.model.sys.user.role.SysUserRole;
import org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyAssembler;

/**
 * describe 用户角色关联关系
 *
 * @author Jia wei Wu
 * @date 2023/05/17 11:19 晚上
 * @see DefaultDDDLazyAssembler
 **/

public class SysUserRoleDTOAssembler {


    /**
     * describe 应用层入参转换成 持久层入参
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/
    public static SysUserRole toUserRole(SysUserRoleCommand sysUserRoleCommand) {
        if (null != sysUserRoleCommand) {
            SysUserRole sysUserRole = new SysUserRole();
            sysUserRole.setCreateTime(sysUserRoleCommand.getCreateTime());
            sysUserRole.setId(sysUserRoleCommand.getId());
            sysUserRole.setIsDeleted(sysUserRoleCommand.getIsDeleted());
            sysUserRole.setRoleId(sysUserRoleCommand.getRoleId());
            sysUserRole.setUpdateTime(sysUserRoleCommand.getUpdateTime());
            sysUserRole.setUserId(sysUserRoleCommand.getUserId());
            return sysUserRole;
        }
        return null;
    }

    /**
     * describe 持久层领域对象转换成DTO对象
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/
    public static SysUserRoleDTO fromUserRole(SysUserRole sysUserRole) {
        if (null != sysUserRole) {
            SysUserRoleDTO sysUserRoleDTO = new SysUserRoleDTO();
            sysUserRoleDTO.setCreateTime(sysUserRole.getCreateTime());
            sysUserRoleDTO.setId(sysUserRole.getId());
            sysUserRoleDTO.setIsDeleted(sysUserRole.getIsDeleted());
            sysUserRoleDTO.setRoleId(sysUserRole.getRoleId());
            sysUserRoleDTO.setUpdateTime(sysUserRole.getUpdateTime());
            sysUserRoleDTO.setUserId(sysUserRole.getUserId());
            return sysUserRoleDTO;
        }
        return null;
    }

}